<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>个人SOP</title>
	<link rel="stylesheet" href="/layui/css/layui.css">
	<link rel="stylesheet" href="/hyqcss/public.css">
	<style type="text/css">
		body{
			background: #e9e9e9;
		}
		/*公共头部带搜索*/
		.public_container{
			margin: 20px;
			background: #fff;
		}
		.public_title_container{
			height: 54px;
			padding: 0 20px;
			font-size: 14px;
			display: flex;
			align-items: center;
			background: #f9f9f9;
			border-bottom: 1px solid #f0f0f0;
		}
		.public_buttonSearch_container{
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 20px;
			background: #fff;
		}
		.public_buttonSearch_container a{
			color: #fff;
			background-color: #1e9fff;
			text-shadow: 0 -1px 0 rgba(0,0,0,.12);
			height: 24px;
			padding: 4px 15px;
			font-size: 14px;
			border-radius: 2px;
			display: flex;
			align-items: center;
			cursor: pointer;
		}
		.public_Search_container{
			position: relative;
		}
		.public_Search_container input{
			width: 240px;
			height: 32px;
			border: 1px solid #d9d9d9;
		}
		.public_Search_container i{
			position: absolute;
			bottom: 6px;
			right: 10px;
			cursor: pointer;
		}
		/*公共头部带搜索 end*/
		.public_table_container{
			padding: 0 20px 20px 20px;
		}
	</style>
</head>
<body>
	
	<div class="public_container">
		<!-- /*公共头部带搜索*/ -->
		<div class="public_content">
			<div class="public_title_container">
				<p>个人SOP</p>
			</div>
			<div class="public_buttonSearch_container">
				<a href="add_sop.html">创建规则</a>
				<div class="public_Search_container">
				<form class="layui-form client-filter" action="">
					<input type="text" name="title" required  lay-verify="required" placeholder="输入要搜索的名称" autocomplete="off" class="layui-input">
					<button lay-submit lay-filter="" style="float:right;margin-top: -4px;border: none;"><i class="layui-icon layui-icon-search" ></i></button>
				</form>
				</div>
			</div>
		</div>
		<!-- /*公共头部带搜索*/ end -->
		<!-- 公共表格部分 -->
		<form class="layui-form">
			<div class="public_table_container">
				<table class="layui-table" lay-skin="line">
					<colgroup>
						<col width="20%">
						<col width="10%">
						<col width="20%">
						<col width="15%">
						<col width="35%">
					</colgroup>
					<thead>
						<tr>
							<th>名称</th>
							<th>创建人</th>
							<th>创建时间</th>
							<th>开关</th>
							<th>操作</th>
						</tr> 
					</thead>
					<tbody>
						{loop $personage as $personage}
						<tr>
							<td>{$personage->rule_name}</td>
							<td>{$personage->founder}</td>
							<td>{date('Y-m-d H:i:s',$personage->ctime)}</td>

							<td>
								<div class="table-public-switch">
									<input type="checkbox" name="switch" lay-skin="switch" data-value="{$personage->id}"  lay-filter="switchTest" lay-text="开启|关闭" {if $personage->status==1}checked{/if} >
								</div>
							</td>
							<td>
								<a type="button" class="table-public-btn" onclick="addUser('{$personage->id}')">添加客服/员工</a>
								<a type="button" class="table-public-btn" onclick="delgroup('{$personage->id}')">删除</a>
								<a href="update-{$personage->id}.html" class="table-public-btn" >修改</a>
								<a href="sop_xq-{$personage->id}.html" class="table-public-btn" >详情</a>
							</td>
						</tr>
						{/loop}
					</tbody>
				</table>
			</div>
		</form>
		<!-- 公共表格部分 end-->
		<div class="main-container-h pageing-container-h">
	        <div class="pageing-content-h">
	           <span>{$p->totalnum}条/{$p->totalpage}页</span> 
	        </div>
			<ul class="pageing-content-h">
	           {P weidogsadmin}
			</ul> 
	    </div>
		<!-- 公共表格部分 end-->
	</div>
	
	<script src="/cdn/jquery.js"></script>
	<script src="/layui/layui.js"></script>
	<script src="/js/ajax.js"></script>
	<script type="text/javascript">
		// 弹窗
		layui.use('layer', function(){
			var layer = layui.layer;
		}); 
		// 表单
		layui.use('form', function(){
			var form = layui.form;

		  //监听提交
		  form.on('submit(formDemo)', function(data){
		  	layer.msg(JSON.stringify(data.field));
		  	return false;
		  });
		});
	</script>
	<script type="text/javascript">
		layui.use(['form'], function(){
		var form = layui.form,layer = layui.layer
		  //监听指定开关
		form.on('switch(switchTest)', function(data){
			var id = $(this).data('value');
		    if(this.checked){
		    	myAjaxPost(false, true, 'sop_status_k.html', { id:id}, function (resp) {
		    		if(resp.status == "success"){
		    			layer.msg(resp.msg);
		    		}
		    		layer.msg(resp.msg);
		    	})
		    }else{
		    	myAjaxPost(false, true, 'sop_status.html', { id:id}, function (resp) {
		    		if(resp.status == "success"){
		    			layer.msg(resp.msg);
		    		}
		    		layer.msg(resp.msg);
		    	})
		    }
		   });
		});
		function delgroup(id){
			myAjaxPost(false, true, 'delete_sop.html', { id:id}, function (resp) {
	    		if(resp.status == "success"){
	    			layer.msg(resp.msg);
	    			setTimeout(function(){
	                    location.reload();
	                },500);
	    		}
	    		layer.msg(resp.msg);
	    	})
		}


		function addUser(id){
			layer.open({
				type: 2,
				title: '添加员工',
				shadeClose: true,
				shade: 0.2,
				area: ['700px', '600px'],
				content: 'selectuser-'+id+'.html'
			}); 
		}


		function search(){
			var name = $("#title").val();
			myAjaxPost(false, true, '', { name:name}, function (resp) {
				console.log(resp);
			})
		}
	</script>
</body>
</html>